package com.e3.core.base;

import java.util.Date;

import com.e3.web.core.model.SuperModel;

public class SuperQueryService extends AbstractSuperService{

	protected <T extends SuperModel> T entityToModel(T model,SuperEntity entity){

		Date currentDate = new Date();
		
		Long createTime = entity.getCreateTime();
		Date date = currentDate;
		if(createTime!=null&&createTime > 0){
			date = new Date(createTime);
		}
		model.setCreateTime(date);
		model.setCreateUserId(entity.getCreateUserId());		
			
		Long modifyTime = entity.getModifyTime();
		date = currentDate;
		if(modifyTime!=null&&modifyTime>0){
			date = new Date(modifyTime);
		}
		model.setModifyTime(date);
		model.setModifyUserId(entity.getModifyUserId());
		
		return model;
	}
	
	protected <T extends SuperModel> T ocEntityToModel(T model,SuperEntity entity){

		model = entityToModel(model, entity);
		
		SuperOCEntity ocEntity = (SuperOCEntity)entity;
		model.setCorpId(ocEntity.getCorpId());
		
		return model;
	}

}
